{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Minimum Cuts to Divide a Circle"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #geometry #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #几何 #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: numberOfCuts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #分割圆的最少切割次数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>圆内一个 <strong>有效切割</strong>&nbsp;，符合以下二者之一：</p>\n",
    "\n",
    "<ul>\n",
    "\t<li>该切割是两个端点在圆上的线段，且该线段经过圆心。</li>\n",
    "\t<li>该切割是一端在圆心另一端在圆上的线段。</li>\n",
    "</ul>\n",
    "\n",
    "<p>一些有效和无效的切割如下图所示。</p>\n",
    "\n",
    "<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2022/10/29/alldrawio.png\" style=\"width: 450px; height: 174px;\" /></p>\n",
    "\n",
    "<p>给你一个整数&nbsp;<code>n</code>&nbsp;，请你返回将圆切割成相等的&nbsp;<code>n</code>&nbsp;等分的&nbsp;<strong>最少</strong>&nbsp;切割次数。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2022/10/24/11drawio.png\" style=\"width: 200px; height: 200px;\" /></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>n = 4\n",
    "<b>输出：</b>2\n",
    "<b>解释：</b>\n",
    "上图展示了切割圆 2 次，得到四等分。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2022/10/24/22drawio.png\" style=\"width: 200px; height: 201px;\" /></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>n = 3\n",
    "<b>输出：</b>3\n",
    "<strong>解释：</strong>\n",
    "最少需要切割 3 次，将圆切成三等分。\n",
    "少于 3 次切割无法将圆切成大小相等面积相同的 3 等分。\n",
    "同时可以观察到，第一次切割无法将圆切割开。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= n &lt;= 100</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [minimum-cuts-to-divide-a-circle](https://leetcode.cn/problems/minimum-cuts-to-divide-a-circle/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [minimum-cuts-to-divide-a-circle](https://leetcode.cn/problems/minimum-cuts-to-divide-a-circle/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['4', '3']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if n > 1 and n % 2 else n // 2\n",
    "        # if n == 1:\n",
    "        #     return 0\n",
    "        # return n // 2 if n % 2 == 0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        ans = 0\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n%2==0:\n",
    "            ans = n//2\n",
    "        else:\n",
    "            ans = n\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        elif n%2==0:\n",
    "            return n//2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        if n%2==0:\n",
    "            return n//2\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n % 2 == 0 or n == 1:\n",
    "            return int(n/2)\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        return n\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n ==1:\n",
    "            return 0\n",
    "        return n if n%2 else n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1: return 0\n",
    "        return n if n & 1 else n // 2\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1 :\n",
    "            return 0;\n",
    "\n",
    "        if n % 2 == 0:\n",
    "            return n // 2;\n",
    "\n",
    "        return n;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1 or n == 2:\n",
    "            return n - 1\n",
    "        l, r = -1, 3\n",
    "        res = 3\n",
    "        for i in range(3, n):\n",
    "            if i % 2 != 0:\n",
    "                res += l\n",
    "                l -= 1\n",
    "            else:\n",
    "                res += r\n",
    "                r += 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if (n > 1 and n & 1) else n >> 1\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        elif n%2==0:\n",
    "            return int(n/2)\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:return 0\n",
    "        if n % 2 == 0:return int(n/2)\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if (n>1 and n&1) else n // 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        elif n%2==0:\n",
    "            return n//2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        return n // 2 if n & 1 == 0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:return 0\n",
    "        if n % 2 == 0:return n // 2\n",
    "        else: return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if n%2 and n>1 else n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if n % 2 and n != 1 else int(n/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n % 2 == 0 or n == 1:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "            \n",
    "        if n % 2  == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        #没有陷阱，为基数时，用半径分割，为偶数时，用直径分割\n",
    "        #特殊值处理，为1时不进行分割\n",
    "        if n==1:\n",
    "            return 0\n",
    "        elif n&1:\n",
    "            return n\n",
    "        else:\n",
    "            return n>>1\n",
    "\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        else:\n",
    "            return n if n%2==1 else n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n ==1:\n",
    "            return 0\n",
    "        elif n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        return n//2 if not n % 2 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1: return 0\n",
    "        if n%2!=0:\n",
    "            return n\n",
    "        return int(n/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:return 0\n",
    "        if n%2==0:return n//2\n",
    "        else:return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        elif n%2 == 0:\n",
    "            return int(n/2)\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return 0 if n == 1 else n if n % 2 else n // 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return 0 if n == 1 else n // 2 if n % 2 == 0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return int(n / 2)\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        else:\n",
    "            if n%2:\n",
    "                return n\n",
    "            else:\n",
    "                return n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return 0 if n == 1 else n //2 if n % 2 == 0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        tmp = 1\n",
    "        k = 0\n",
    "        if n != 1:\n",
    "            if n%2 == 0:\n",
    "                return int(n/2)\n",
    "            else:\n",
    "                return n\n",
    "        else:\n",
    "            return 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:return 0\n",
    "        if n%2==0:return n//2\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if n>1 and n&1 else n>>1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        else:\n",
    "            if n%2 == 0:\n",
    "                return n//2\n",
    "            else:\n",
    "                return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        elif n == 1:\n",
    "            return 0\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if 180 * n % 360 == 0:\n",
    "            count = n // 2\n",
    "        else:\n",
    "            count = n\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if n%2 and n>1 else n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        elif n%2 == 0:\n",
    "            return n//2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        return n if n % 2 != 0 else n // 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n != 1:\n",
    "            return n//2 if n % 2 == 0 else n\n",
    "        else:\n",
    "            return 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        else:\n",
    "            return n//2 if n%2 == 0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n//2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n ==1:\n",
    "            return 0\n",
    "        elif n % 2 == 0:\n",
    "            return n // 2\n",
    "        else:\n",
    "            return n \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        return n if n%2==1 else n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        return n // 2 if n % 2 == 0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n%2:\n",
    "            return n if n>1 else 0\n",
    "        else:\n",
    "            return n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1: return 0\n",
    "        if n%2!=0:\n",
    "            return n\n",
    "        return n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        s = 0\n",
    "\n",
    "        if n % 2 == 0:\n",
    "            s = n / 2\n",
    "        elif n == 1:\n",
    "            pass\n",
    "\n",
    "        else:\n",
    "            s = n\n",
    "        return int(s)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        elif n==2:\n",
    "            return 1\n",
    "        elif n==3:\n",
    "            return 3\n",
    "        else:\n",
    "            return (n+1)//2 if n%2==0 else n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return int(n / 2)\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        return n if n&1 else n//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        elif n%2 == 0:\n",
    "            return int(n/2)\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        return n if n > 1 and n % 2 else n // 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        elif n%2==0:\n",
    "            return int(n/2)\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        n = n-1\n",
    "        if n%2:\n",
    "            return (n+1)>>1\n",
    "        return n + bool(n)\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return n//2\n",
    "        else:\n",
    "            return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n == 1:\n",
    "            return 0\n",
    "        if n % 2 == 0:\n",
    "            return int(n / 2)\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        if n==1:\n",
    "            return 0\n",
    "        if n%2==0:\n",
    "            n/=2\n",
    "            return int(n)\n",
    "        \n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def numberOfCuts(self, n: int) -> int:\n",
    "        result = 0\n",
    "        if n%2==0:\n",
    "            result=n/2\n",
    "        elif n==1:\n",
    "            result = 0\n",
    "        else:\n",
    "            result = n\n",
    "        return int(result)"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
